local FightInterface = require("gameLogic.fightSkill.sequence.FightInterface")
local FightMove = class("FightMove", FightInterface)
local Vector3 = require("utils.Vector3")

local SPEED = 20

function FightMove:ctor(actor, tarPos)
    self._actor = actor
    self._tarPos = tarPos
    FightMove.super.ctor(self)
end

function FightMove:_update()
    if self._sequence then
        return
    end
    self._sequence = DOTween.Sequence()
    local pos = self._actor.transform.position
    local distance = Vector3.distance(pos, self._tarPos)
    local time = distance / SPEED
    local move = self._actor.transform:DOMove(self._tarPos, time)
    self._actor:setMoving(true)
    self._sequence:Append(move)
    self._sequence:AppendCallback(
        function()
            self._actor:setMoving(false)
            self._isDone = true
        end
    )
end

return FightMove
